using System.Runtime.InteropServices;

namespace WindowsAPI.PE
{
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct IMAGE_SECTION_HEADER
    {
        [StructLayout(LayoutKind.Explicit)]
        public struct _Misc
        {
            [FieldOffset(0)]
            public readonly uint PhysicalAddress;
            [FieldOffset(0)]
            public readonly uint VirtualSize;
        }

        private const int IMAGE_SIZEOF_SHORT_NAME = 8;

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = IMAGE_SIZEOF_SHORT_NAME)]
        public readonly char[] RawName;

        public readonly _Misc Misc;
        public readonly uint VirtualAddress;
        public readonly uint SizeOfRawData;
        public readonly uint PointerToRawData;
        public readonly uint PointerToRelocations;
        public readonly uint PointerToLinenumbers;
        public readonly ushort NumberOfRelocations;
        public readonly ushort NumberOfLinenumbers;
        public readonly uint Characteristics;

        public string Name { get { return new string(RawName); } }

        public override string ToString() { return Name; }
    }
}